package com.itheima.redis.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;

@Configuration
@EnableConfigurationProperties(RedisProperties.class)
//底层是使用@Import({EnableConfigurationPropertiesRegistrar.class})，使用@Import导入的类会被Spring加载到IOC容器中。
public class RedisAutoConfigure {

//    注入redis参数配置类
    @Autowired
    public RedisProperties redisProperties;
    /**
     * 提供一个jedisbean
     * @return
     */
    @Bean
    public Jedis jedis(RedisProperties redisProperties){
        return new Jedis(redisProperties.getHost(),redisProperties.getPort());
    }
}
